<!--{__NOLAYOUT__}-->
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="__STATIC__/js/layui/css/layui.css">
</head>
<body>

<div style="margin: 5px;">
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">登录账号</label>
            <div class="layui-input-inline">
                <input type="text" name="username" value="{$username}" required  disabled="disabled" lay-verify="required" placeholder="账号" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">最大长度为15汉字、字母、数字</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">用户昵称</label>
            <div class="layui-input-inline">
                <input type="text" name="usernick" value="{$usernick}" required  lay-verify="required" placeholder="昵称" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">最大长度为15汉字、字母、数字</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password"   placeholder="如果不修改请留空" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">密码最小长度为6个字符</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">重复密码</label>
            <div class="layui-input-inline">
                <input type="password" name="rpassword"   placeholder="如果不修改请留空" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">请重复输入一次密码</div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户身份</label>
            <div class="layui-input-inline">
                <select id="userstats" name="userstats"  lay-verify="required">
                    <!--<option value=""></option>-->
                    {if condition="$userstat==1"}
                    <option value="2" >普通用户</option>
                    <option value="1" selected>管理员</option>
                    {else /}
                    <option value="2" selected>普通用户</option>
                    <option value="1" >管理员</option>
                    {/if}

                </select>
            </div>
            <div class="layui-form-mid layui-word-aux">选择用户身份</div>

        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<input type="hidden" name="name" value="lalal">
<script src="__STATIC__/js/layui/layui.js" charset="utf-8"></script>


<script>

    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    layui.use('form', function(){
        var form = layui.form;
        var $ = layui.$;
        //监听提交
        form.on('submit(formDemo)', function(data){
            var postdata = data.field;
            if (postdata.password.length > 0) {

                if (postdata.password != postdata.rpassword) {
                    layer.msg('两次密码输入不一致');
                    return false;
                }
                if (postdata.password.length < 6) {
                    layer.msg('密码长度小于6');
                    return false;
                }
            }

            $.ajax({
                type: 'post'
                , dataType: 'json'
                , url: '/admin/usermanger/edit'
                , data: postdata
                , success: function (obj) {
                    if (obj.code === -1) {
                        layer.msg(obj.msg);
                    } else if (obj.code === 1) {
                        parent.layer.close(index);
                    }

                }
            });
            return false;
        });
    });
</script>
</body>
</html>